package com.un.web.topic.controller;

import com.un.core.common.R;
import com.un.web.topic.domian.entity.TopicJavaAnswer;
import com.un.web.topic.service.TopicJavaAnswerService;
import com.un.web.topic.service.impl.TopicJavaAnswerServiceImpl;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

/**
 * (topic_java_answer)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/topic_java_answer")
public class TopicJavaAnswerController {
    /**
     * 服务对象
     */
    @Autowired
    private TopicJavaAnswerService topicJavaAnswerService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public TopicJavaAnswer selectOne(Integer id) {
        return topicJavaAnswerService.getById(id);
    }

    @GetMapping("list/{topicId}")
    public R findList(@PathVariable Integer topicId){
        return R.success(topicJavaAnswerService.listByTopicId(topicId));
    }


    @PostMapping("save")
    public R save(@RequestBody TopicJavaAnswer topicJavaAnswer){
        topicJavaAnswerService.saveOrUpdate(topicJavaAnswer);
        return R.success();
    }

}
